/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.team1662.commands;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.DriverStationLCD;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.team1662.RobotMap;


/**
 *
 * @author programmer
 */
public class Drive extends CommandBase {
    
    //The light sensor sends True because it's reflected. 
    //I need to programme for it to detect when the signal is false
    //then add a reset variable.

    private boolean trigger = false;

    public Drive() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        requires(drivetrain);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
        drivetrain.tankDrive(0, 0);
        drivetrain.cheezit(0);
        drivetrain.shooter(0);
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        oi.updateButton();
        drivetrain.tankDrive(oi.getRightStick(), oi.getLeftStick());
        SmartDashboard.putNumber("Right Joystick: ", oi.getRightStick());
        SmartDashboard.putNumber("Left Joystick: ", oi.getLeftStick());
        SmartDashboard.putNumber("Left Motor: ", drivetrain.getLeftMotor());
        SmartDashboard.putNumber("Right Motor: ", drivetrain.getRightMotor());
        SmartDashboard.putNumber("Pickup 1: ", drivetrain.getChMotor());
        SmartDashboard.putNumber("Pickup 2: ", drivetrain.getChMotor2());
        drivetrain.cheezit(oi.getSomething());
        
        /*if (RobotMap.limitSwitch4.get() == true && RobotMap.limitSwitch3.get() == true && 
                RobotMap.limitSwitch2.get() == true && RobotMap.limitSwitch1.get() == true) {*/
        if(RobotMap.limitSwitch1.get() == true)
            drivetrain.shooter(oi.getConveyorThrottle());
        else
            drivetrain.shooter(0);
        System.out.println(RobotMap.limitSwitch1.get());
        System.out.println(RobotMap.limitSwitch2.get());
        /*
        } else if (RobotMap.limitSwitch4.get() == trigger && RobotMap.tripNum == 4) {
            drivetrain.shooter(0);
        } else if (RobotMap.limitSwitch3.get() == trigger && RobotMap.tripNum == 3) {
            drivetrain.shooter(0);
        } else if (RobotMap.limitSwitch2.get() == trigger && RobotMap.tripNum == 2) {
            drivetrain.shooter(0);
        } else if (RobotMap.limitSwitch1.get() == trigger && RobotMap.tripNum == 1) {
            drivetrain.shooter(0);
        } else 
            drivetrain.shooter(oi.getConveyorThrottle());
        */
        System.out.println(oi.getSomething());
        //drivetrain.shooter(oi.getConveyorThrottle());
        //DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser1, 1, "" + RobotMap.limitSwitch1.get());
        //DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser2, 1, "" + RobotMap.limitSwitch2.get());
        //DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser3, 1, "" + RobotMap.limitSwitch3.get());
        //DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser4, 1, "" + RobotMap.limitSwitch4.get());
        DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser5, 1, "" + RobotMap.tripNum);
        DriverStationLCD.getInstance().updateLCD();
    }
    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return false;
    }

    // Called once after isFinished returns true
    protected void end() {
        drivetrain.tankDrive(0, 0);
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}
